package com.wdc.patterns.singleton.demo7;

import java.lang.reflect.Constructor;

public class Client {
    public static void main(String[] args) throws Exception {
        Class<Singleton> clazz = Singleton.class;
        Constructor<Singleton> cons = clazz.getDeclaredConstructor();
        //取消访问检查
        cons.setAccessible(true);
        //通过反射创建对象
        Singleton s1 = cons.newInstance();
        Singleton s2 = cons.newInstance();

        System.out.println(s1 == s2);
    }
}
